﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Edit</title>
    <link href="~/Content/lib/layui/css/layui.css" rel="stylesheet" />
    <script src="~/Content/lib/layui/layui.js"></script>
</head>
<body>
    <form class="layui-form" action="">
        <input type="hidden" value="@ViewBag.A.id" id="id" />
        <div class="layui-form-item">
            <label class="layui-form-label">分类名称</label>
            <div class="layui-input-block">
                <input type="text" value="@ViewBag.A.TypeName" id="TypeName" required lay-verify="required" placeholder="分类名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        //Demo
        layui.use(['form'], function () {
            var form = layui.form;

            var $ = layui.$;

            //监听提交
            form.on('submit(formDemo)', function (data) {
                $.ajax({
                    url: "/Back/NewsType/Update",
                    type: "post",
                    data: {
                        TypeName: $("#TypeName").val(),
                        id: $("#id").val()
                    },
                    dataType: "json",
                    success: function (res) {
                        if (res.code == 0) {
                            parent.layer.close()
                            parent.location.reload()
                        }
                    }
                })
                return false;
            });
        });
    </script>
</body>
</html>
